package question2;

public class Student {
    private  String name;
    private  String sex;
    private  int age;

    public Student() {
    }

    public Student(String name, String sex, int age) {
        this.name = name;
        this.sex = sex;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        if (sex!="男"||sex!="女"){
            throw new SexException("性别异常");
        }else {
            this.sex = sex;
        }
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age<15||age>50){
            throw new AgeException("年龄异常编写测试类");
        }
        else{
            this.age = age;
        }
    }
}
